package org.zch.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.zch.common.ApiResult;
import org.zch.entity.po.IdeaPO;
import org.zch.entity.po.WorksPO;
import org.zch.service.IdeaService;

/**
 * 意见反馈
 */
@RestController
@RequestMapping("/idea")
@Api(tags = "意见反馈")
public class IdeaController {

    @Autowired
    private IdeaService ideaService;

    /**
     * 添加意见反馈*/
    @ApiOperation(value = "添加意见反馈", notes = "添加意见反馈")
    @PostMapping("/addIdea")
    public ApiResult addIdea(@RequestBody IdeaPO ideaPO){
        return ApiResult.ok(ideaService.save(ideaPO));
    }

    /**
     * 根据id删除内容*/
    @ApiOperation(value = "根据id删除内容", notes = "根据id删除内容")
    @PostMapping("/deleteById")
    public ApiResult deleteById(@RequestParam("code") String id){
        return ApiResult.ok(ideaService.deleteById(Integer.parseInt(id)));
    }

    /**
     * 获取所有数据*/
    @ApiOperation(value = "获取所有数据", notes = "获取所有数据")
    @GetMapping("/findAll")
    public ApiResult findAll(){
        return ApiResult.ok(ideaService.findAll());
    }

}
